package com.xian.cloud.config;


import com.codingapi.tx.springcloud.feign.TransactionRestTemplateInterceptor;
import com.codingapi.tx.springcloud.http.TransactionHttpRequestInterceptor;
import feign.RequestInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @Author: xlr
 * @Date: Created in 下午9:58 2018/11/13
 */
public class MyConfiguration {

    @Autowired
    private RestTemplateBuilder builder;

    @Bean
    public RestTemplate restTemplate() {
        return builder.interceptors(new TransactionHttpRequestInterceptor()).build();
    }

    @Bean
    public RequestInterceptor requestInterceptor(){
        return new TransactionRestTemplateInterceptor();
    }
}
